   import javax.swing.*;

   public class Calculator
   {
   
      public static void main (String []args)
      {
      
      
         String input = JOptionPane.showInputDialog(null, "Pease enter number:\n1:Box\n2:Circle\n3:Point\n4:Square\n5:Rectangle\n6:Cylinder\n7:Rhombus\n8:Prism\n9:Cube\n10:Sphere\n11:Trapezoid\n12:Cone\n13:Triangle\n14:Ellipsoid\n15:Regular Polygon\n16:Pyramid");
      
         if (input.equals ("1"))
         {
            String input1 = JOptionPane.showInputDialog(null, "1: Volume of box\n2: Surface Area of an open box\n3: Surface Area of a closed box");
            
            if (input1.equals("1"))
            {
               String number1 = JOptionPane.showInputDialog(null, "Please enter length: ");
               String number2 = JOptionPane.showInputDialog(null, "Please enter length: ");
               String number3 = JOptionPane.showInputDialog(null, "Please enter length: ");
            	
               double length = Double.parseDouble(number1);
               double width = Double.parseDouble(number2);
               double height = Double.parseDouble(number3);
            	
               Box a=new Box (length, width, height);
            	
               JOptionPane.showInputDialog(null, "The volume is " + a.getVolume());//for the volume of the box
            	
            }
            if (input1.equals("2"))
            {
               String number1 = JOptionPane.showInputDialog(null, "Please enter length: ");
               String number2 = JOptionPane.showInputDialog(null, "Please enter length: ");
               String number3 = JOptionPane.showInputDialog(null, "Please enter length: ");
            	
               double length = Double.parseDouble(number1);
               double width = Double.parseDouble(number2);
               double height = Double.parseDouble(number3);
            	
               Box b = new Box (length, width, height);
            	
               JOptionPane.showInputDialog("The surface area of the open box is " + b.getSAOpen()); //for surface area of an open box
            
            }
            if (input1.equals("3"))
            {
               String number1 = JOptionPane.showInputDialog(null, "Please enter length: ");
               String number2 = JOptionPane.showInputDialog(null, "Please enter length: ");
               String number3 = JOptionPane.showInputDialog(null, "Please enter length: ");
            	
               double length = Double.parseDouble(number1);
               double width = Double.parseDouble(number2);
               double height = Double.parseDouble(number3);
            
               Box c = new Box (length, width, height);
               JOptionPane.showInputDialog("The surface area of the closed box is " + c.getSAClosed()); //for surface area of a closed box
            
                  
            }
            if (input.equals ("2"))
            {
               String input2 = JOptionPane.showInputDialog(null, "1: Area of Circle\n2: Circumference of a Circle");
               if (input2.equals("1"))
               {
               
                  String number4 = JOptionPane.showInputDialog(null, "Enter Radius: ");
                  double radius = Double.parseDouble(number4);
                  double diameter = 0;
               
                  Circle d=new Circle(radius, diameter);
                  System.out.println("The area is " + d.getArea());//for the area of the circle
               
               }				
               if (input2.equals ("2"))
               {
                  String input3 = JOptionPane.showInputDialog(null, "1: I have the radius\n2: I have the diameter");
                  if (input3.equals("1"))
                  {
                     String number4 = JOptionPane.showInputDialog(null, "Enter radius: ");
                     double radius = Double.parseDouble(number4);
                     double diameter = 0;
                  
                     Circle e=new Circle(radius, diameter);
                     System.out.println("The circumference is " + e.getCRadius());//for circumference of the circle using radius
                  }
                  if(input3.equals("2"))
                  {
                     String number5 = JOptionPane.showInputDialog(null, "Enter diameter: ");
                     double diameter = Double.parseDouble(number5);
                     double radius = 0;
                  
                     Circle f=new Circle(radius, diameter);
                     System.out.println("The circumference is " + f.getCDia());//  for circumference of the circle using diamete
                  
                  }
               
               }       
            }
            if (input.equals ("3"))
            {
               String input4 = JOptionPane.showInputDialog(null, "1: Distance\n2: Midpoint\n3: Slope");
               if (input4.equals ("1"))
               {
                  String numberX= JOptionPane.showInputDialog(null, "x: ");
                  double x = Double.parseDouble(numberX);
               
                  String numberY= JOptionPane.showInputDialog(null, "x: ");
                  double y = Double.parseDouble(numberY);
               
                  String numberX2= JOptionPane.showInputDialog(null, "x: ");
                  double x2 = Double.parseDouble(numberX2);
               
                  String numberY2= JOptionPane.showInputDialog(null, "x: ");
                  double y2 = Double.parseDouble(numberY2);
               
                  Point p=new Point (x, y);
                  Point p2=new Point (x2, y2);
               
                  JOptionPane.showInputDialog("The distance between the points is " + p.getDistance(p2));//finds distance 
               }
            
            
               if (input4.equals ("2"))
               {
                  String numberX= JOptionPane.showInputDialog(null, "x: ");
                  double x = Double.parseDouble(numberX);
               
                  String numberY= JOptionPane.showInputDialog(null, "x: ");
                  double y = Double.parseDouble(numberY);
               
                  String numberX2= JOptionPane.showInputDialog(null, "x: ");
                  double x2 = Double.parseDouble(numberX2);
               
                  String numberY2= JOptionPane.showInputDialog(null, "x: ");
                  double y2 = Double.parseDouble(numberY2);
               
                  Point p=new Point (x, y);
                  Point p2=new Point (x2, y2);
               
                  System.out.println("The midpoint of the two points is " + p.getMidPoint(p2));//finds midpoint
               }
               if (input4.equals ("2"))
               {
                  String numberX= JOptionPane.showInputDialog(null, "x: ");
                  double x = Double.parseDouble(numberX);
               
                  String numberY= JOptionPane.showInputDialog(null, "x: ");
                  double y = Double.parseDouble(numberY);
               
                  String numberX2= JOptionPane.showInputDialog(null, "x: ");
                  double x2 = Double.parseDouble(numberX2);
               
                  String numberY2= JOptionPane.showInputDialog(null, "x: ");
                  double y2 = Double.parseDouble(numberY2);
               
                  Point p=new Point (x, y);
                  Point p2=new Point (x2, y2);
               
                  System.out.println("The slope of the line connecting the two points is " + p.getSlope(p2));//finds slope
               
               }
            
            }
            if (input.equals ("4"))
            {
               String input5 = JOptionPane.showInputDialog(null, "1: Area\n2: Perimeter");
            	
               if (input5.equals("1"))
               {
                  String number6= JOptionPane.showInputDialog(null, "side: ");
                  double side = Double.parseDouble(number6);
               	 
                  Square a=new Square (side);
                  System.out.println("The area is " + a.getArea());//for area of the square
               }
               if (input5.equals("2"))
               {
                  String number7= JOptionPane.showInputDialog(null, "side: ");
                  double side = Double.parseDouble(number7);
               
                  Square a=new Square (side);
                  System.out.println("The perimeter is " + a.getPerimeter());//for perimeter of the square
               }
            
            }
            if (input.equals ("5"))
            {
               String input5 = JOptionPane.showInputDialog(null, "1: Area\n2: Perimeter");
            	
               if (input5.equals("1"))
               {
                  String number= JOptionPane.showInputDialog(null, "length: ");
                  String number2= JOptionPane.showInputDialog(null, "width: ");
               
               
                  double length = Double.parseDouble(number);
                  double width = Double.parseDouble(number2);
               	
                  Rectangle z = new Rectangle (length, width);
                  System.out.println("The area is " + z.getArea());//for area of the rectangle
               
               	
               }
               if (input5.equals("2"))
               {
                  String number= JOptionPane.showInputDialog(null, "length: ");
                  String number2= JOptionPane.showInputDialog(null, "width: ");
               
               
                  double length = Double.parseDouble(number);
                  double width = Double.parseDouble(number2);
               	
                  Rectangle y = new Rectangle (length, width);
                  System.out.println("The perimeter is " + y.getPerimeter());//for perimeter of the rectangle
               }
            }
            if (input.equals ("6"))
            {
            
				String input5 = JOptionPane.showInputDialog(null, "1: Volume\n2: Surface A");
            	
               if (input5.equals("1"))
               {
                  String number= JOptionPane.showInputDialog(null, "radius: ");
                  String number2= JOptionPane.showInputDialog(null, "height: ");
               
               
                  double radius = Double.parseDouble(number);
                  double height = Double.parseDouble(number2);
						
						Cylinder a=new Cylinder (radius, height);
               	System.out.println("The volume is " + a.getVolume());//for volume of the cylinder
					}
					 if (input5.equals("2"))
               {
                  String number= JOptionPane.showInputDialog(null, "radius: ");
                  String number2= JOptionPane.showInputDialog(null, "height: ");
               
               
                  double radius = Double.parseDouble(number);
                  double height = Double.parseDouble(number2);
						
						Cylinder a=new Cylinder (radius, height);
						System.out.println("The surface area is " + a.getSA());//for surface area of the cylinder
               }          
            
            }
            if (input.equals ("7"))
            {
            
               Rhombus a=new Rhombus (d1, d2);//You can use this for both area and perimeter, d1 and d2 stand for its diagonals
               System.out.println("The area is " + a.getArea());//for area of the rhombus 
               System.out.println("The perimeter is " + a.getPerimeter2());//for perimeter of the rhombus using its diagonals
            
               Rhombus b=new Rhombus (side);//You can use this only for perimeter
               System.out.println("The area is " + b.getPerimeter());//for perimeter of the rhombus using its sides
            
            
            }
            if (input.equals ("8"))
            {
            
               Prism a=new Prism (B, h);//B stands for area of the base, h stands for the height; Use this only for volume
               System.out.println("The volume is " + a.getVolume());//for volume of the prism
            
               Prism b=new Prism (B, h, p); //B stands for area of the base, h stands for the height, p stands for perimeter of the base; Use this only for surface area
               System.out.println("The surface area is " + b.getSurfaceArea());//for surface area of the prism
            
               RectPrism c=new RectPrism (length, width, height);//only for rectangular prisms
               System.out.println("The volume is " + c.getVolume());//for volume of the rect prism
               System.out.println("The surface area is " + c.getSurfaceArea());//for volume of the rect prism
            
            
            }
            if (input.equals ("9"))
            {
            
               Cube a=new Cube (side);
               System.out.println("The volume is " + a.getVolume());//for volume of the cube
               System.out.println("The surface area is " + a.getSA());//for surface area of the cube
            }
            if (input.equals ("10"))
            {
            
               Sphere a=new Sphere (radius);
               System.out.println("The volume is " + a.getVolume());//for volume of the sphere
               System.out.println("The surface area is " + a.getSurfaceArea());//for surface area of the sphere
            
            }
            if (input.equals ("11"))
            {
            
               Trapezoid a=new Trapezoid (height, base1, base2); //Only for area
               System.out.println("The area is " + a.getArea());//for area of the trapezoid
            
               Trapezoid b=new Trapezoid (b1, b2, s1, s2); //Only for perimeter
               System.out.println("The perimeter is " + b.getPerimeter());//for area of the trapezoid
            
            
            
            }
            if (input.equals ("12"))
            {
            
               Cone a=new Cone (radius, slantheight, height); //Use this only for surface area
               System.out.println("The surface area is " + a.getSurfaceArea());
            
               Cone b=new Cone (radius, height); //Use this only for volume
               System.out.println("The volume is " + b.getVolume());
            
            
            
            }
            if (input.equals ("13"))
            {
            
               Triangle a=new Triangle (base, height); //Use this only for area
               System.out.println("The area is " + a.getAreaBh());
            
               Triangle b=new Triangle (s1, s2, s3); //Use this for both area and perimeter
               if (s1+s2>s3 && s2+s3>s1 && s1+s3>2)
               {
                  System.out.println("The area is " + b.getAreaSides());
                  System.out.println("The perimeter is " + b.getTrianglePerimeter());
               }
               
               else
                  System.out.println("Your sides do not make a triangle. Try again.");
            
               Triangle c=new Triangle (side);//For equilateral triangles
               System.out.println("The area is " + c.getAreaEqual());
               System.out.println("The perimeter is " + c.getPerimeterEqual());		
            }
            if (input.equals ("14"))
            {
            
               Ellipsoid a=new Ellipsoid (radius, radius1, radius2);
               System.out.println("The volume is " + a.getVolume());
            }
            if (input.equals ("15"))
            {
            
               RegularPolygon a=new RegularPolygon (number, length); //You can use this for both area and perimeter
               System.out.println("The area is " + a.getArea());
               System.out.println("The perimeter is " + a.getPerimeter());
            
               RegularPolygon b=new RegularPolygon (apothem, number, length);//Use this only for area
               System.out.println("The area is " + b.getArea2());
            }
         
            if (input.equals ("16"))
            {
            
               Pyramid a=new Pyramid (B, h);//B stands for area of the base, h stands for the height; Use this only for volume
               System.out.println("The volume is " + a.getVolume()); 				
            
               Pyramid b=new Pyramid (B, p, s); //B stands for area of the base, s stands for the slant height, p stands for perimeter of the base; Use this only for surface area
               System.out.println("The surface area is " + b.getSA());
            }
         }
      }
   }
